//
//  CustomTabBarView.m
//  WeChatHelper
//
//  Created by Mac on 14-3-26.
//  Copyright (c) 2014年 bang yi bang. All rights reserved.
//

#import "CustomTabBarView.h"
@implementation CustomTabBarView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
       
    }
    return self;
}

-(id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        
    }
    return self;
}
-(id)init
{
    if (self=[super init]) {
        
    }
    return self;
}

-(void)setHidden:(BOOL)hidden{

    [super setHidden:hidden];

    
    for (UIView *subView in self.superview.subviews) {
        if ([subView isKindOfClass:NSClassFromString(@"UITransitionView")]) {
            CGRect frame = subView.frame;
            frame.size.height = kUI_SCREEN_HEIGHT;
            subView.frame = frame;
        }
    }
}

-(void)initView
{
    [self changAction:0];
}

- (void)updateView
{
    UIApplication *application = [UIApplication sharedApplication];
    if (application.applicationIconBadgeNumber>0) {
        self.labelNew.hidden = NO;
    }else{
        self.labelNew.hidden = YES;
    }
}

-(void)selectItem:(NSInteger)num
{
    [self buttonWasSelected:num];
}

- (IBAction)changAction:(UIButton *)sender
{
    [self.delegate buttonWasSelected:sender.tag];
    [self buttonWasSelected:sender.tag];
}

- (void)buttonWasSelected:(NSInteger)index
{
    self.button1.selected = NO;
    self.button2.selected = NO;
    self.button3.selected = NO;
    self.button4.selected = NO;
    self.button5.selected = NO;
    switch (index) {
        case 0:{
            self.button1.selected = YES;
        }
            break;
        case 1:{
            self.button2.selected = YES;
        }
            break;
        case 2:
            self.button3.selected = YES;
            break;
        case 3:
            self.button4.selected = YES;
            break;
        case 4:
            self.button5.selected = YES;
            break;
        default:
            break;
    }
}

@end
